﻿// NahidaProject-Generic-BuildExample.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <cassert>

#include <BloomFilter.h>
#include <HTTPRequest.h>
#include <Logger.h>
#include <SortModule.h>

int main(int argc, char** argv) {
	NahidaProject::BloomFilter<100> bloomFilter;

	bloomFilter.Set("Object A");
	bloomFilter.Set("Object B");
	bloomFilter.Set("Object C");

	assert(bloomFilter.Test("Object A") == 1);

	assert(bloomFilter.Test("Object A") == 1);
	assert(bloomFilter.Test("Object B") == 1);
	assert(bloomFilter.Test("Object C") == 1);
	assert(bloomFilter.Test("Object D") == 0);

	assert(bloomFilter.EstimateElementCount(), 3);

	std::cout << "Used bits: " << bloomFilter.GetUsedBits() << std::endl;
	std::cout << "Load factor: " << bloomFilter.LoadFactor() << std::endl;
	std::cout << "False positive rate: " << bloomFilter.EstimateFalsePositiveRate(3) << std::endl;
	bloomFilter.Clear();
	assert(bloomFilter.GetUsedBits() == 0);

	NahidaProject::HTTPRequest::AsyncHTTPRequest request;
	request.SetHeader("Authorization", "Bearer 123");
	request.SetHeader("User-Agent", "HTTPRequest/1.0");

	request.Post("http://postman-echo.com/post", [](const std::string& response) {
		std::cout << "Echo post:\n\n" << response << "\n\n";
	}, NahidaProject::HTTPRequest::ContentType::json, R"({"name": "olli", "job": "pro coder"})");

	while (!request.Server()) {
		
	 }

	request.Get("http://postman-echo.com/get", [](const std::string& response) {
		std::cout << response << std::endl;
	});

	while (!request.Server()) {

	 }

	std::cout << "" << std::endl;

	NahidaProject::Logger::GetInstance()->Open("TestRead.log");
	NahidaProject::Logger::GetInstance()->SetMax(1024);

	Debug("This is a debug imformation");
	Information("This is a imformation imformation");
	Warning("This is a %s imformation", "warning");
	Error("This is a error imformation");
	// FATAL("Hello NahidaProject"); Will be stop and return -1

	std::vector<int> a = { 5, 6, 7, 2, 1, 4, 3 };
	std::vector<int> b = { 1, 2, 3, 4, 5, 6, 7 };

	assert(NahidaProject::SortModule::BubbleSort(a) == b);
	assert(NahidaProject::SortModule::InsertSort(a) == b);
	assert(NahidaProject::SortModule::SelectSort(a) == b);

	return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件
